<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>Webdesign ToolBox</title>
	<meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
	<? include("toolbox/functions.php"); ?>
	<link href="toolbox/tools.css" rel="stylesheet" type="text/css" media="screen" />
	<script type="text/javascript" src="toolbox/jquery-mini.js"></script>
	<script type="text/javascript" src="toolbox/jquery.scrollTo.js"></script>
	<script language="javascript" type="text/javascript">
	<!--
	
		jQuery.fn.fadeToggle = function(speed, easing, callback) {
			return this.animate({opacity: 'toggle'}, speed, easing, callback); 
		};

		jQuery().ready(function(){
		
			$.easing.elasout = function(x, t, b, c, d) {
				var s=1.70158;var p=0;var a=c;
				if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
				if (a < Math.abs(c)) { a=c; var s=p/4; }
				else var s = p/(2*Math.PI) * Math.asin (c/a);
				return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
			};
		
			$.scrollTo( '#lastEdit', 800, {easing:'elasout'} );
			
			$(".nextErr").click( function(){ $.scrollTo( '.no', 800, {easing:'elasout'} ); });
			
			$("p").dblclick( function(){ 
		
				pContent = $(this).html();
				pType = $(this).attr("class");
				pFile = $(this).parent().attr("class");
				$(this).html('');			
				$(this).after('<form action="helphp.php" method="post"><input type="hidden" name="process" value="fileReg"/><input type="hidden" name="file" value="'+pFile+'"/><input type="hidden" name="Type" value="'+pType+'"/><input type="text" tabindex="1" size="40" name="Inhalt" value="'+pContent+'"/><//form>');
			});
		});
		
	// -->
	</script>

	<?
		$self = "helphp.php";		
		
		if(isset($_POST["process"]))
			$process = $_POST["process"];
		else $process = "std";
		
		if(isset($_POST["file"])){
			$file = $_POST["file"];
		}
		else $file = "std";
		
	   /// Hier wird die aktualisierte Datei gespeichert...
	   if ($process == 'fileReg') {
		   echo "<h3>You have changed: <br/> the " . $_POST["Type"]  . "<br/>of: " . $_POST["file"] . "<br/>to " . $_POST["Inhalt"] . "</h3>"; 
		   
		   $str = join('', file($_POST["file"]));
		   if($_POST["Type"] == 'title'){
			   $str = preg_replace("=<title>(.*)</title>=siU", '<title>'.$_POST["Inhalt"].'</title>', $str);
		   }
	   
		   else if($_POST["Type"] == 'desc')
			   $str = preg_replace('=<meta name\="description" content\=".*"./>=siU', '<meta name="description" content="'.$_POST["Inhalt"].'" />', $str);
		   
		   if (!$handle = fopen($_POST["file"], "w+")) {return false;}
		   if (!fwrite($handle, $str)) {return false;}
		   fclose($handle);
	   }
		
	?>


</head>

<body>

<div id="wrapper">
<div id="signet"><img src="toolbox/signet.jpg" alt="HelPHP - A Webdesigners Toolbox" <? if($process == "std") echo 'id="lastEdit"' ?> /></div>
<div id="navi">

<ul>
	<li><a href="<? echo $self."?action=meta"; ?>">Meta</a></li>
	<li><a href="<? echo $self."?action=images"; ?>">Images</a></li>
	<li><a href="<? echo $self."?action=info"; ?>">PHP Info</a></li>
	<li><a href="<? echo $self."?action=smallies"; ?>">Smallies</a></li>
</ul>

</div>
<a href="#" class="nextErr">nextError</a>

<? 

////* MENÜ */////
if (isset($_GET["action"]))
	$action = $_GET["action"];
else
	$action = "meta";
	
switch ($action) {
	case "meta":
		viewtree("./", $file); 
		break;
	case "images":
		include ("toolbox/alt_img.php");
		break;
	case "info":
		phpinfo();
		break;
	case "smallies":
		dir4search();
		break;
	default:
		echo "<h1>Welcome</h1>";
}

?>
</div>
</body>
</html>